
var path = require("path");

// const VueLoaderPlugin = require('vue-loader/lib/plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const webpack = require('webpack')
module.exports = {
         mode:'none',
    entry:'./src/main.js',
    output:{
        filename:'[name].[chunkhash].bundle.js',
        path:path.join(__dirname,'dist'),
        //打包后一些图片等文件位置 防止到根目录找不到
        publicPath:'dist/'
    },
    // devtool:'source-map',
    module:{
    //其他资源模块的加载规则
        rules:[{
            test:/.js$/,
            use:{
                loader:'babel-loader',
                options:{
                    presets:['@babel/preset-env']
                }
            }
        },{
            test:/.css$/,
            use:[      
                'style-loader',
                'css-loader',
                // 'less-loader'
                ]             
        },{
            test:/.less$/,
            use:[      
                'style-loader',
                'css-loader',
                'less-loader'
                ]             
        },{
            test: /\.(png|jpe?g|gif)$/,
            use: {
                loader: 'url-loader',
                options: {
                    name: "img/[contenthash].[ext]",
                    limit: 5 * 1024
                }
            }
        },{
            test:/.html$/,
            use:'html-loader',
            //添加属性option
        },
        {
            test:/.vue$/,
            use:['vue-loader']

        }

    ]
    },
    plugins:[
        new CleanWebpackPlugin (),
        // new VueLoaderPlugin()
        new HtmlWebpackPlugin({
            title: 'vue',
  template: path.resolve(__dirname, 'public/index.html')
        }),
        new webpack.DefinePlugin({ // 默认值配置
            // 值要求的是一个代码片段
            BASE_URL: '"/"'
            })
        // new CopyWebpackPlugin([
        //     path.resolve(__dirname, 'public/favicon.ico')
        //   ])
    ],

}